<!-- saved from url=(0014)about:internet -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>ToastSkin.as</title>
<link rel="stylesheet" type="text/css" href="../../../../SourceStyles.css"/>
</head>

<body><pre><span class="ActionScriptComment">////////////////////////////////////////////////////////////////////////////////
</span><span class="ActionScriptComment">//
</span><span class="ActionScriptComment">//  Licensed to the Apache Software Foundation (ASF) under one or more
</span><span class="ActionScriptComment">//  contributor license agreements.  See the NOTICE file distributed with
</span><span class="ActionScriptComment">//  this work for additional information regarding copyright ownership.
</span><span class="ActionScriptComment">//  The ASF licenses this file to You under the Apache License, Version 2.0
</span><span class="ActionScriptComment">//  (the "License"); you may not use this file except in compliance with
</span><span class="ActionScriptComment">//  the License.  You may obtain a copy of the License at
</span><span class="ActionScriptComment">//
</span><span class="ActionScriptComment">//      http://www.apache.org/licenses/LICENSE-2.0
</span><span class="ActionScriptComment">//
</span><span class="ActionScriptComment">//  Unless required by applicable law or agreed to in writing, software
</span><span class="ActionScriptComment">//  distributed under the License is distributed on an "AS IS" BASIS,
</span><span class="ActionScriptComment">//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
</span><span class="ActionScriptComment">//  See the License for the specific language governing permissions and
</span><span class="ActionScriptComment">//  limitations under the License.
</span><span class="ActionScriptComment">//
</span><span class="ActionScriptComment">////////////////////////////////////////////////////////////////////////////////
</span>
<span class="ActionScriptpackage">package</span> <span class="ActionScriptDefault_Text">spark</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">skins</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">mobile</span>
<span class="ActionScriptBracket/Brace">{</span>
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">events</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">Event</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">geom</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">Point</span>;
    
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">core</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">DPIClassification</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">core</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">mx_internal</span>;
    
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">spark</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">components</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">Toast</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">spark</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">components</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">supportClasses</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">StyleableTextField</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">spark</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">filters</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">GlowFilter</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">spark</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">skins</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">mobile</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">supportClasses</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">MobileSkin</span>;
    
    <span class="ActionScriptASDoc">/**
     *  ActionScript-based skin for the Toast control. 
     *  The colors of the component can
     *  be customized using styles. This class is responsible for all of the
     *  graphics drawing, with no additional fxg assets.
     *  
     *  @langversion 3.0
     *  @playerversion AIR 3
     *  @productversion Flex 4.6
     *
     *  @see spark.components.Toast
     */</span>    
    <span class="ActionScriptReserved">public</span> <span class="ActionScriptclass">class</span> <span class="ActionScriptDefault_Text">ToastSkin</span> <span class="ActionScriptReserved">extends</span> <span class="ActionScriptDefault_Text">MobileSkin</span>
    <span class="ActionScriptBracket/Brace">{</span>
        
        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//  Constructor
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptASDoc">/**
         *  Constructor.
         * 
         *  @langversion 3.0
         *  @playerversion AIR 3
         *  @productversion Flex 4.6
         **/</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">ToastSkin</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">super</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptReserved">switch</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">applicationDPI</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">DPIClassification</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">DPI_320</span>:
                <span class="ActionScriptBracket/Brace">{</span>
                    <span class="ActionScriptDefault_Text">layoutStrokeWeight</span> <span class="ActionScriptOperator">=</span> 4;
                    <span class="ActionScriptDefault_Text">layoutInnerVerticalPadding</span> <span class="ActionScriptOperator">=</span> 4;
                    <span class="ActionScriptDefault_Text">layoutInnerHorizontalPadding</span> <span class="ActionScriptOperator">=</span> 16;
                    <span class="ActionScriptDefault_Text">layoutOuterPadding</span> <span class="ActionScriptOperator">=</span> 40;
                    <span class="ActionScriptDefault_Text">layoutDropShadowStrength</span> <span class="ActionScriptOperator">=</span> 16;
                    <span class="ActionScriptReserved">break</span>;
                <span class="ActionScriptBracket/Brace">}</span>
                <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">DPIClassification</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">DPI_240</span>:
                <span class="ActionScriptBracket/Brace">{</span>
                    <span class="ActionScriptDefault_Text">layoutStrokeWeight</span> <span class="ActionScriptOperator">=</span> 3;
                    <span class="ActionScriptDefault_Text">layoutInnerVerticalPadding</span> <span class="ActionScriptOperator">=</span> 3;
                    <span class="ActionScriptDefault_Text">layoutInnerHorizontalPadding</span> <span class="ActionScriptOperator">=</span> 12;
                    <span class="ActionScriptDefault_Text">layoutOuterPadding</span> <span class="ActionScriptOperator">=</span> 30;
                    <span class="ActionScriptDefault_Text">layoutDropShadowStrength</span> <span class="ActionScriptOperator">=</span> 12;
                    <span class="ActionScriptReserved">break</span>;
                <span class="ActionScriptBracket/Brace">}</span>
                <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">DPIClassification</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">DPI_160</span>:
                <span class="ActionScriptReserved">default</span>:
                <span class="ActionScriptBracket/Brace">{</span>
                    <span class="ActionScriptDefault_Text">layoutStrokeWeight</span> <span class="ActionScriptOperator">=</span> 2;
                    <span class="ActionScriptDefault_Text">layoutInnerVerticalPadding</span> <span class="ActionScriptOperator">=</span> 2;
                    <span class="ActionScriptDefault_Text">layoutInnerHorizontalPadding</span> <span class="ActionScriptOperator">=</span> 8;
                    <span class="ActionScriptDefault_Text">layoutOuterPadding</span> <span class="ActionScriptOperator">=</span> 20;
                    <span class="ActionScriptDefault_Text">layoutDropShadowStrength</span> <span class="ActionScriptOperator">=</span> 8;
                    <span class="ActionScriptReserved">break</span>;
                <span class="ActionScriptBracket/Brace">}</span>
            <span class="ActionScriptBracket/Brace">}</span>
            
            <span class="ActionScriptComment">// Add our surrouding drop-shadow
</span>            <span class="ActionScriptReserved">this</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">filters</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptBracket/Brace">[</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">GlowFilter</span><span class="ActionScriptBracket/Brace">(</span>0x000000<span class="ActionScriptOperator">,</span> 1.0<span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">layoutDropShadowStrength</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">layoutDropShadowStrength</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">]</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        
        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//  Variables
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        
        
        <span class="ActionScriptASDoc">/**
         *  The stroke weight outlining the graphics of the skin.
         *
         *  @langversion 3.0
         *  @playerversion AIR 3
         *  @productversion Flex 4.6
         */</span>
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">layoutStrokeWeight</span>:<span class="ActionScriptDefault_Text">Number</span>;
        
        <span class="ActionScriptASDoc">/**
         *  The padding around the label
         *
         *  @langversion 3.0
         *  @playerversion AIR 3
         *  @productversion Flex 4.6
         */</span>
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">layoutInnerVerticalPadding</span>:<span class="ActionScriptDefault_Text">Number</span>;
        
        <span class="ActionScriptASDoc">/**
         *  The padding around the label
         *
         *  @langversion 3.0
         *  @playerversion AIR 3
         *  @productversion Flex 4.6
         */</span>
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">layoutInnerHorizontalPadding</span>:<span class="ActionScriptDefault_Text">Number</span>;
        
        <span class="ActionScriptASDoc">/**
         *  The padding between the contents and the edges of the parent
         *
         *  @langversion 3.0
         *  @playerversion AIR 3
         *  @productversion Flex 4.6
         */</span>
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">layoutOuterPadding</span>:<span class="ActionScriptDefault_Text">Number</span>;
        
        <span class="ActionScriptASDoc">/**
         *  The distance to show the drop-shadow around the background box
         *
         *  @langversion 3.0
         *  @playerversion AIR 3
         *  @productversion Flex 4.6
         */</span>
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">layoutDropShadowStrength</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> 8;
        
        <span class="ActionScriptASDoc">/**
         *  The label for the text in the notification box
         *     Exposed for styling purposes only.
         *
         *  @langversion 3.0
         *  @playerversion AIR 3
         *  @productversion Flex 4.6
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">labelDisplay</span>:<span class="ActionScriptDefault_Text">StyleableTextField</span>;
        
        
        <span class="ActionScriptComment">//----------------------------------
</span>        <span class="ActionScriptComment">//  hostComponent
</span>        <span class="ActionScriptComment">//----------------------------------
</span>        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">_hostComponent</span>:<span class="ActionScriptDefault_Text">Toast</span>;
        
        <span class="ActionScriptASDoc">/**
         * @copy spark.skins.spark.ApplicationSkin#hostComponent
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptReserved">get</span> <span class="ActionScriptDefault_Text">hostComponent</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptDefault_Text">Toast</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">return</span> <span class="ActionScriptDefault_Text">_hostComponent</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptASDoc">/**
         *  @private
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptReserved">set</span> <span class="ActionScriptDefault_Text">hostComponent</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">value</span>:<span class="ActionScriptDefault_Text">Toast</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_hostComponent</span> <span class="ActionScriptOperator">===</span> <span class="ActionScriptDefault_Text">value</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptReserved">return</span>;
            
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">removeEventListener</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">Event</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">CHANGE</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">textChanged_handler</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptDefault_Text">_hostComponent</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">value</span>;
            
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">addEventListener</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">Event</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">CHANGE</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">textChanged_handler</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//  Overridden Methods
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        
        <span class="ActionScriptASDoc">/**
         *  @private
         *  Redraw the graphics of the skin as necessary
         */</span>
        <span class="ActionScriptReserved">override</span> <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">drawBackground</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">unscaledWidth</span>:<span class="ActionScriptDefault_Text">Number</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">unscaledHeight</span>:<span class="ActionScriptDefault_Text">Number</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">super</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">drawBackground</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">unscaledWidth</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">unscaledHeight</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptDefault_Text">graphics</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">clear</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptComment">// get our styles
</span>            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">contentBackgroundColor</span>:<span class="ActionScriptDefault_Text">uint</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">getStyle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptString">"contentBackgroundColor"</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">contentBackgroundAlpha</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">getStyle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptString">"contentBackgroundAlpha"</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">cornerRadius</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">getStyle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptString">"cornerRadius"</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">strokeColor</span>:<span class="ActionScriptDefault_Text">uint</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">getStyle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptString">"strokeColor"</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">strokeAlpha</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">getStyle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptString">"strokeAlpha"</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptComment">// calculate our size based on label dimensions and skin properties
</span>            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">calculatedWidth</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">textWidth</span> <span class="ActionScriptOperator">+</span> 2 <span class="ActionScriptOperator">*</span> <span class="ActionScriptDefault_Text">layoutInnerHorizontalPadding</span> <span class="ActionScriptOperator">+</span> 2 <span class="ActionScriptOperator">*</span> <span class="ActionScriptDefault_Text">layoutStrokeWeight</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">calculatedHeight</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">height</span> <span class="ActionScriptOperator">+</span> 2 <span class="ActionScriptOperator">*</span> <span class="ActionScriptDefault_Text">layoutInnerVerticalPadding</span> <span class="ActionScriptOperator">+</span> 2 <span class="ActionScriptOperator">*</span> <span class="ActionScriptDefault_Text">layoutStrokeWeight</span>;;
            
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">notificationParentGlobalPt</span>:<span class="ActionScriptDefault_Text">Point</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">notificationParent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">localToGlobal</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Point</span><span class="ActionScriptBracket/Brace">(</span>0<span class="ActionScriptOperator">,</span> 0<span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">posX</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">notificationParentGlobalPt</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">x</span> <span class="ActionScriptOperator">+</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">notificationParent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">width</span> <span class="ActionScriptOperator">-</span> <span class="ActionScriptDefault_Text">calculatedWidth</span><span class="ActionScriptBracket/Brace">)</span> <span class="ActionScriptOperator">/</span> 2;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">parentBottom</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">notificationParentGlobalPt</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">y</span> <span class="ActionScriptOperator">+</span> <span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">notificationParent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">height</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">posY</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">parentBottom</span> <span class="ActionScriptOperator">-</span> <span class="ActionScriptDefault_Text">calculatedHeight</span> <span class="ActionScriptOperator">-</span> <span class="ActionScriptDefault_Text">layoutOuterPadding</span>;
            
            <span class="ActionScriptComment">// draw our notification box
</span>            <span class="ActionScriptDefault_Text">graphics</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">lineStyle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">layoutStrokeWeight</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">strokeColor</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">strokeAlpha</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptReserved">true</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">graphics</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">beginFill</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">contentBackgroundColor</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">contentBackgroundAlpha</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">graphics</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">drawRoundRectComplex</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">posX</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">posY</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">calculatedWidth</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">calculatedHeight</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">cornerRadius</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">cornerRadius</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">cornerRadius</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">cornerRadius</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">graphics</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">endFill</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">graphics</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">lineStyle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptASDoc">/**
         *  @private
         *  Resize and reposition as necessary
         */</span>
        <span class="ActionScriptReserved">override</span> <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">layoutContents</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">unscaledWidth</span>:<span class="ActionScriptDefault_Text">Number</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">unscaledHeight</span>:<span class="ActionScriptDefault_Text">Number</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">super</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">layoutContents</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">unscaledWidth</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">unscaledHeight</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">notificationParentGlobalPt</span>:<span class="ActionScriptDefault_Text">Point</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">notificationParent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">localToGlobal</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Point</span><span class="ActionScriptBracket/Brace">(</span>0<span class="ActionScriptOperator">,</span> 0<span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">)</span>;

            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">parentBottom</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">notificationParentGlobalPt</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">y</span> <span class="ActionScriptOperator">+</span> <span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">notificationParent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">height</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">posX</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">notificationParentGlobalPt</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">x</span> <span class="ActionScriptOperator">+</span> <span class="ActionScriptDefault_Text">layoutOuterPadding</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">posY</span>:<span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">parentBottom</span> <span class="ActionScriptOperator">-</span> <span class="ActionScriptDefault_Text">layoutOuterPadding</span> <span class="ActionScriptOperator">-</span> <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">height</span>; 
            
            <span class="ActionScriptDefault_Text">setElementPosition</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">posX</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">posY</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        
        <span class="ActionScriptASDoc">/**
         * @private
         */</span>
        <span class="ActionScriptReserved">override</span> <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">createChildren</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">super</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">createChildren</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptDefault_Text">labelDisplay</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">StyleableTextField</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">createInFontContext</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">StyleableTextField</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">wordWrap</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">true</span>;
            <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">multiline</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">true</span>;
            <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">styleName</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">this</span>;
            <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">setStyle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptString">"textAlign"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptString">"center"</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">commitStyles</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptComment">// Set the max width of our label
</span>            <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">width</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">notificationParent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">width</span> <span class="ActionScriptOperator">-</span> 2 <span class="ActionScriptOperator">*</span> <span class="ActionScriptDefault_Text">layoutOuterPadding</span>;
            <span class="ActionScriptDefault_Text">addChild</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">text</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">label</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptASDoc">/**
         *  @private
         */</span>
        <span class="ActionScriptReserved">override</span> <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">measure</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptComment">// update the label height
</span>            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">measuredTextSize</span>:<span class="ActionScriptDefault_Text">Point</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">mx_internal</span><span class="ActionScriptOperator">::</span><span class="ActionScriptDefault_Text">measuredTextSize</span>;
            
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">height</span> <span class="ActionScriptOperator">!=</span> <span class="ActionScriptDefault_Text">measuredTextSize</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">y</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">height</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">measuredTextSize</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">y</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//  Event Handlers
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        
        <span class="ActionScriptASDoc">/**
         * When the label on the hostComponent changes, update the label and
         * underlying background to reflect the new text.
         */</span>
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">textChanged_handler</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">event</span>:<span class="ActionScriptDefault_Text">Event</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptDefault_Text">labelDisplay</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">text</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">_hostComponent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">label</span>;
            
            <span class="ActionScriptDefault_Text">invalidateDisplayList</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">invalidateSize</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
    <span class="ActionScriptBracket/Brace">}</span>
<span class="ActionScriptBracket/Brace">}</span>
</pre></body>
</html>
